from Page.page_login import Login
from Page.page_open_account import OpenAccount
from Page.page_register import PageRegister
from Tools.tools import DriverTools
from config import BASE_URL, PHONE, NAME, CARD
from script import log


class TestOpenAccount(object):

    def setup_method(self):
        driver = DriverTools.get_driver()
        # driver.get(BASE_URL + "/common/member/login")
        driver.get(BASE_URL + "/common/member/reg")
        # self.lg = Login(driver)
        self.op = OpenAccount(driver)
        self.reg_page = PageRegister(driver)

    def teardown_method(self):
        DriverTools.close_driver()

    def test01_openAccount_success(self):
        #     登录成功
        # self.lg.login_succeses('14718809983', "test123456")  # 已注册未开通
        # 注册成功
        self.reg_page.register("18715678907", "test123456", "8888")
        phone=PHONE
        self.op.open_account(NAME, CARD)  # 不存在得身份证号码
        self.op.now_open_account()
        #       切换窗口，获取成功页面
        result = self.op.assert_success_openAcount()
        log.info(f"执行结果{result}")
        # 断言
        print(phone)
        assert "OK" in result
